﻿/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is Jutsu Opensource Framework.
  
  The Initial Developer of the Original Code is 
  ALCARAZ Marc <ekameleon@gmail.com>.
  Portions created by the Initial Developer are Copyright (C) 2012-2013
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
  Alternatively, the contents of this file may be used under the terms of
  either the GNU General Public License Version 2 or later (the "GPL"), or
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  in which case the provisions of the GPL or the LGPL are applicable instead
  of those above. If you wish to allow use of your version of this file only
  under the terms of either the GPL or the LGPL, and not to allow others to
  use your version of this file under the terms of the MPL, indicate your
  decision by deleting the provisions above and replace them with the notice
  and other provisions required by the LGPL or the GPL. If you do not delete
  the provisions above, a recipient may use your version of this file under
  the terms of any one of the MPL, the GPL or the LGPL.
  
*/

package jutsu.vo 
{
    import system.data.SimpleValueObject;
    import system.hack;
    
    /**
     * The MenuVO defines an entry in the menu model of the application.
     */
    public class MenuVO extends SimpleValueObject 
    {
        use namespace hack ;
        
        /**
         * Creates a new MenuVO instance.
         * @param init A generic object containing properties with which to populate the newly instance. If this argument is null, it is ignored
         */
        public function MenuVO( init:Object = null )
        { 
            super( init );
            if( id === undefined )
            {
                id = COUNTER++ ; // autoincrement
            }
        }
        
        /**
         * The color of the menu item.
         */
        public var color:* ;
        
        /**
         * The command to launch when the menu item is selected.
         */
        public var command:* ;
        
        /**
         * The description of menu item.
         */
        public var description:String ;
        
        /**
         * The icon of the menu item.
         */
        public var icon:* ;
        
        /**
         * Optional init object to initialize the menu item.
         */
        public var init:* ;
        
        /**
         * The label of the menu item.
         */
        public var label:String ;
        
        /**
         * Defines a String to set the google analytics pageView message.
         */
        public var pageview:String;
         
        /**
         * The policy of menu item.
         */
        public var policy:* ;
        
        /**
         * The id of linked state of this menu item.
         */
        public var stateID:* ;
        
        /**
         * The type of the menu item.
         */
        public var type:String ;
        
        /**
         * The uri of this value object to launch.
         */
        public var uri:String ;
        
        /**
         * Returns the generic Object representation of this object.
         * @return the generic Object representation of this object.
         */
        public override function toObject():Object
        {
            var object:Object = 
            { 
                id:id,
                color:color,
                command:command,
                description:description,
                icon:icon,
                init:init,
                label:label,
                pageview:pageview,
                policy:policy,
                stateID:stateID,
                type:type,
                uri:uri
            };
            return object ;
        }
        
        /**
         * Returns the string representation of this object.
         * @return the string representation of this object.
         */
        public override function toString():String
        {
            var args:Array = ["MenuVO" ] ;
            if ( id != null )
             {
                args.push("id") ;
            }
            if ( label != null && label.length > 0 )
            {
                args.push("label") ;
            }
            if ( type != null )
            {
                args.push("type") ;
            }
            if ( command )
            {
                args.push("command") ;
            }
            if (color != null)
            {
                args.push( "color" ) ;
            }
            if (pageview != null)
            {
                args.push("pageview") ;
            }
            if ( stateID != null )
            {
                args.push("stateID") ;
            }
            if ( icon != null )
            {
                args.push("icon") ;
            }
            return formatToString.apply( this, args ) ;
        }
        
        /**
         * @private
         */
        hack static var COUNTER:uint = 0 ;
    }
}
